/**
 * @copyright   2010-2017, The Titon Project
 * @license     http://opensource.org/licenses/BSD-3-Clause
 * @link        http://titon.io
 */

@include export("table") {
    $titon-table-class: generate-class-name($titon-table);

    #{$titon-table-class} {
        width: 100%;
        background: theme-setting("bg-lightest");
        border-collapse: collapse;

        th,
        td {
            padding: theme-setting("medium-padding");
            border: 1px solid theme-setting("bg-light");
        }

        // Move headings to bottom
        thead th {
            vertical-align: bottom;
        }

        // Allow for multiple tbody's
        tbody + tbody {
            border-top-width: 2px;
        }

        // Row colors
        thead tr,
        tfoot tr {
            background: theme-setting("bg-light");
        }

        // Divider
        tbody tr#{generate-class-name($titon-table, "divider")} {
            background: theme-setting("bg-light");
        }
    }

    #{generate-class-name($titon-table, "responsive")} {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
    }

    //-------------------- States --------------------//

    #{$titon-table-class} {
        &.is-striped tbody tr {
            &:nth-child(even) {
                background: lighten(theme-setting("bg-lightest"), 1.5%);
            }
        }

        &.is-sortable thead th {
            padding: 0;

            > a,
            > span {
                padding: theme-setting("medium-padding");
                display: block;
            }
        }

        &.has-hover tbody tr:not(#{generate-class-name($titon-table, "divider")}):hover {
            background: #fff;
        }
    }
}
